<template>
	<div class="pinderation" style="margin-top: 0;">
		<div class="identity-type">
			<span>基本信息</span>
		</div>
		<div class="essen_list">
			<p>
				<span>车牌号</span>
				<b class="carNo">{{fgTranInfo.carPlateNo}}</b>
			</p>
			<p>
				<span>司机姓名</span>
				<b class="driver">{{fgTranInfo.carDriverName}}</b>
			</p>
			<p>
				<span>司机电话</span>
				<b class="phone">{{fgTranInfo.carDriverMobile}}</b>
			</p>
			<p>
				<span>入场时间</span>
				<b class="time">{{fgTranInfo.enterTimeStr}}</b>
			</p>
		</div>
		<div class="identity-type">
			<span>物料详情</span>
			<span style="float: right;padding-right: 1.1rem;">单位(吨)</span>
		</div>
		<table border="0" cellpadding="0" cellspacing="0">
			<thead>
				<tr>
					<th>物料<br />名称</th>
					<th>装车<br />重量</th>
					<th>物料过<br />磅重量</th>
					<th>重量<br />误差</th>
				</tr>
			</thead>
			<tbody>
				<tr v-for="(item,index) in fgGoodslist" :key="index">
					<td>{{item.goodsName}}</td>
					<td>{{item.goodsCarWeight}}</td>
					<td>{{item.goodsWeight}}</td>
					<td>{{item.weightWucha}}</td>
				</tr>
			</tbody>
			<tfoot>
				<tr>
					<td>物料合计</td>
					<td>{{goodsCarWeight | toFixed}}</td>
					<td>{{goodsWeight | toFixed}}</td>
					<td>{{weightWucha | toFixed}}</td>
				</tr>
			</tfoot>
		</table>
		<div class="seePonderation">
			<a href="javascript:;" class="seeClick" @click="seeClick">查看过磅单</a>
			<div class="demos-content-padded" >
				<a href="javascript:;" class="weui-btn weui-btn_primary" @click="confirmWeight" v-show="this.$route.query.enterStatus==1">确认重量无误</a>
			</div>

		</div>

	</div>

</template>

<script>
	import {
		viewPoundList,
		confirmPound
	} from '../../config/api'
	import {
		getStore
	} from '../../config/mUtils'
	import { Toast } from 'we-vue'
	export default {
		data() {
			return {
				carNo: this.$route.query.carNo,
				orderNo: this.$route.query.orderNo,
				fgTranInfo: [],
				fgGoodslist: [],
				goodsCarWeight:'',
				goodsWeight:'',
				weightWucha:''
			}
		},
		mounted() {
			viewPoundList(this.carNo, this.orderNo).then(res => {
				console.log(res)
				this.fgTranInfo = res.content.fgTranInfo
				this.fgGoodslist = res.content.fgGoodslist
				for(let i=0;i<this.fgGoodslist.length;i++){
					this.goodsCarWeight += this.fgGoodslist[i].goodsCarWeight*1
					this.goodsWeight += this.fgGoodslist[i].goodsWeight*1
					this.weightWucha += this.fgGoodslist[i].weightWucha*1
				}
			}).catch(err => console.log(err))
		},
		methods: {
			confirmWeight() {
				confirmPound(getStore('SupplierId'),this.carNo,this.orderNo).then(res=>{
					if(res.code==100){
						Toast.success({
							duration: 1200,
							message: res.content
						});
						setTimeout(()=>{
							this.$router.push('/mine')
						},1200)
					}
				}).catch(err=>console.log(err))
			},
			seeClick(){
				this.$router.push({
					path:'LookPonderation',
					query:{
						carNo:this.carNo,
						orderNo:this.orderNo,
						carId:this.fgTranInfo.id
					}
				})
			}
		},
		filters: {
			toFixed(value){
				return Number(value).toFixed(2);
			}
		}
	}
</script>

<style>
</style>
